<!--
 * @Author:shuaishuai
-->
<template>
  <div class="right-content-box">
    <div class="pageTitle">行业煤炭消费趋势分析</div>
    <div class="qiuChart">
      <div ref="qiuChart01" style="width: 570px; height: 790px"></div>
    </div>
    <div class="contentItem">
      <div class="titleBox">
        <div class="title">上升趋势煤炭消费典型行业</div>
        <div ref="pieChart" style="width: 1790px; height: 790px"></div>
      </div>
    </div>
    <div class="contentItem">
      <div class="titleBox">
        <div class="title">供热行业煤炭消费量分析</div>
        <div ref="pieChartTwo" style="width: 1790px; height: 790px"></div>
      </div>
    </div>
    <div class="qiuChart">
      <div ref="qiuChart02" style="width: 570px; height: 790px"></div>
    </div>
    <div class="contentItem">
      <div class="titleBox">
        <div class="title">平稳下行煤炭消费典型行业</div>
        <div ref="pieChart3" style="width: 1790px; height: 790px"></div>
      </div>
    </div>
    <div class="contentItem">
      <div class="titleBox">
        <div class="title">建材行业煤炭消费量分析</div>
        <div ref="pieChart4" style="width: 1790px; height: 790px"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { color } from 'echarts'
import * as echarts from 'echarts'
import { defineComponent } from 'vue'

export default defineComponent({
  data() {
    return {}
  },
  created() {},
  mounted() {
    this.getQiuChart01()
    this.getQiuChart02()
    this.getChart()
    this.getChartTwo()
    this.getChartThree()
    this.getChartFour()
  },
  methods: {
    getQiuChart01() {
      const qiuChart01 = echarts.init(this.$refs.qiuChart01)
      let option = {
        series: [
          {
            type: 'graph',
            layout: 'force',
            force: {
              repulsion: 1040,
              edgeLength: 560
            },
            symbolSize: 150,
            label: {
              show: true,
              fontWeight: 'bold',
              color: '#fff',
              fontSize: 40,
              formatter: function (params) {
                return params.data.name + '\n' + params.data.value + '亿吨'
              }
            },
            data: [
              {
                name: '其他行业',
                value: '11',
                symbolSize: 290,
                itemStyle: {
                  color: 'rgba(65, 178, 186, 1)'
                }
              },
              {
                name: '煤化工行业',
                value: '22',
                symbolSize: 160,
                itemStyle: {
                  color: 'rgba(70, 158, 87, 1)'
                }
              },
              {
                name: '供热行业',
                value: '32',
                symbolSize: 255,
                itemStyle: {
                  color: 'rgba(186, 160, 74, 1)'
                }
              }
            ]
          }
        ]
      }
      qiuChart01.setOption(option, true)
    },
    getQiuChart02() {
      const qiuChart02 = new echarts.init(this.$refs.qiuChart02)
      let option = {
        series: [
          {
            type: 'graph',
            layout: 'force',
            force: {
              repulsion: 1040,
              edgeLength: 560
            },
            symbolSize: 150,
            label: {
              show: true,
              fontWeight: 'bold',
              color: '#fff',
              fontSize: 40,
              formatter: function (params) {
                return params.data.name + '\n' + params.data.value + '亿吨'
              }
            },
            data: [
              {
                name: '炼焦行业',
                value: '11',
                symbolSize: 290,
                itemStyle: {
                  color: 'rgba(127, 94, 204, 1)'
                }
              },
              {
                name: '冶金行业',
                value: '22',
                symbolSize: 160,
                itemStyle: {
                  color: 'rgba(89, 171, 217, 1)'
                }
              },
              {
                name: '供热建材行业',
                value: '32',
                symbolSize: 255,
                itemStyle: {
                  color: 'rgba(196, 85, 26, 1)'
                }
              }
            ]
          }
        ]
      }
      qiuChart02.setOption(option, true)
    },

    getChart() {
      let chart = echarts.init(this.$refs.pieChart)
      let option = {
        tooltip: {
          trigger: 'axis',
          backgroundColor: 'rgba(8,45,74,0.85)',
          borderColor: 'rgb(140,255,74)', //设置边框颜色
          padding: 12,
          axisPointer: {
            type: 'shadow'
          },
          textStyle: {
            fontSize: 40,
            color: '#fff',
            align: 'left'
          },
          formatter: (params) => {
            let arr = [...params]
            let str = ''
            arr.forEach((item, index) => {
              str +=
                '<span style="margin-right:10px;display:inline-block;width:10px;height:10px;border-radius:5px;background-color:' +
                item.borderColor +
                ';"></span>' +
                item.seriesName +
                '  ' +
                item.data +
                '<br />'
            })
            str = arr[0].name + '<br />' + str
            return str
          }
        },
        grid: {
          left: '4%',
          right: '4%',
          bottom: '10%',
          top: '20%',
          containLabel: true
        },
        legend: {
          show: true,
          top: '8%',
          textStyle: {
            fontSize: 40,
            color: '#fff'
          }
          // data: ["煤化行业", "供热行业", "其他行业"],
        },
        xAxis: {
          show: true,
          type: 'category',
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          },
          axisLabel: {
            textStyle: {
              fontSize: 40,
              color: '#fff'
            }
          },
          splitLine: {
            show: true,
            // interval: information.area.length,
            lineStyle: {
              color: 'rgba(180, 228, 255, 0.1)',
              width: 3
            }
          },
          data: ['2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024']
        },
        yAxis: [
          {
            name: '亿吨',
            nameTextStyle: {
              //y轴上方单位的颜色
              color: '#fff',
              fontSize: 40,
              padding: [0, 80, 15, 0]
            },
            type: 'value',
            axisLabel: {
              textStyle: {
                color: '#fff',
                fontSize: 40
              }
            },
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            splitLine: {
              show: false
            }
          }
        ],
        series: [
          {
            name: '煤化工行业',
            type: 'line',
            symbol: 'circle',
            itemStyle: {
              emphasis: {
                symbol: 'circle'
              }
            },
            symbolSize: 20, //标记的大小

            lineStyle: {
              normal: {
                width: 5,
                color: 'rgba(70, 158, 87, 1)'
              }
            },
            itemStyle: {
              //折线拐点标志的样式
              color: '#021958',
              borderColor: 'rgba(70, 158, 87, 1)',
              borderWidth: 5
            },
            data: [1, 0, 1, 4, 10, 8, 1, 3, 3, 5]
          },
          {
            name: '供热行业',
            type: 'line',
            symbol: 'circle',
            symbolSize: 20, //标记的大小
            itemStyle: {
              //折线拐点标志的样式
              color: '#021958',
              borderColor: 'rgba(186, 160, 74, 1)',
              borderWidth: 5
            },
            lineStyle: {
              normal: {
                width: 5,
                color: 'rgba(186, 160, 74, 1)'
              }
            },
            data: [2, 1, 3, 3, 5, 6, 4, 10, 8, 1]
          },
          {
            name: '其他行业',
            type: 'line',
            symbol: 'circle',
            symbolSize: 20,
            itemStyle: {
              //折线拐点标志的样式
              color: '#021958',
              borderColor: 'rgba(65, 178, 186, 1)',
              borderWidth: 5
            },
            lineStyle: {
              normal: {
                width: 5,
                color: 'rgba(65, 178, 186, 1)'
              }
            },
            data: [1, 4, 10, 8, 4, 4, 4, 10, 15, 3]
          }
        ]
      }
      chart.setOption(option, true)
    },
    getChartTwo() {
      const chartsBar = echarts.init(this.$refs.pieChartTwo)
      let option = {
        tooltip: {
          trigger: 'axis',
          backgroundColor: 'rgba(8,45,74,0.85)',
          borderColor: 'rgb(140,255,74)', //设置边框颜色
          padding: 12,
          axisPointer: {
            type: 'shadow'
          },
          textStyle: {
            fontSize: 40,
            color: '#fff',
            align: 'left'
          }
        },
        legend: {
          icon: 'rect',
          itemWidth: 14,
          itemHeight: 5,
          itemGap: 13,
          top: '8%',
          textStyle: {
            fontSize: 40,
            color: '#fff'
          }
        },
        grid: {
          top: 200,
          left: '5%',
          right: '5%',
          bottom: '5%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            axisLine: {
              lineStyle: {
                color: '#57617B'
              }
            },
            axisLabel: {
              interval: 0,
              align: 'center',
              margin: 10,
              color: '#fff',
              rotate: 0,
              textStyle: {
                fontSize: 40
              }
            },
            data: ['2017', '2018', '2019', '2020', '2021', '2022', '2022', '2024'],
            splitLine: {
              show: true,
              // interval: information.area.length,
              lineStyle: {
                color: 'rgba(180, 228, 255, 0.1)',
                width: 2
              }
            }
          },
          {
            axisPointer: {
              show: false
            },
            axisLine: {
              lineStyle: {
                color: '#57617B'
              }
            },
            axisTick: {
              show: false
            },

            position: 'bottom',
            offset: 20
            // data: ['', '', '', '', '', '', '', '', '', '', {
            //     value: '周六',
            //     textStyle: {
            //         align: 'left'
            //     }
            // }, '周日']
          }
        ],
        yAxis: [
          {
            type: 'value',
            name: '亿吨',
            nameTextStyle: {
              color: '#fff',
              fontSize: 40,
              padding: [0, 0, 10, -20]
            },
            splitLine: {
              show: false
            },
            axisTick: {
              show: true
            },
            axisLine: {
              show: false
            },
            axisLabel: {
              show: true,
              textStyle: {
                color: '#fff',
                fontSize: 40
              }
            }
          },
          {
            type: 'value',
            name: '亿平方米',
            nameTextStyle: {
              color: '#fff',
              fontSize: 40,
              padding: [0, 0, 10, -20]
            },
            position: 'right',
            splitLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            axisLine: {
              show: false
            },
            axisLabel: {
              show: true,
              textStyle: {
                color: '#fff',
                fontSize: 40
              }
            }
          }
        ],
        series: [
          {
            name: '增速',
            type: 'line',
            symbolSize: 0, //标记的大小
            color: 'rgba(67, 207, 124, 1)',
            lineStyle: {
              color: 'rgba(67, 207, 124, 1)',
              width: 5
            },
            data: [42, 38, 48, 35, 29, 28, 3, 5]
          },
          {
            name: '供热面积',
            type: 'line',
            // smooth: true,
            yAxisIndex: 1, //使用的 y 轴的 index，在单个图表实例中存在多个 y轴的时候有用
            symbol: 'circle',
            symbolSize: 5,
            showSymbol: false,
            lineStyle: {
              normal: {
                width: 5
              }
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: 'rgba(0, 136, 212, 0.4)'
                    },
                    {
                      offset: 0.8,
                      color: 'rgba(0, 136, 212, 0.2)'
                    }
                  ],
                  false
                ),
                shadowColor: 'rgba(0, 0, 0, 0.2)',
                shadowBlur: 10
              }
            },
            itemStyle: {
              normal: {
                color: 'rgb(0,136,212)',
                borderColor: 'rgba(0,136,212,0.2)',
                borderWidth: 12
              }
            },
            data: [120, 110, 125, 145, 122, 165, 122, 220]
          }
        ]
      }
      chartsBar.setOption(option, true)
    },
    getChartThree() {
      let chart = echarts.init(this.$refs.pieChart3)
      let lineData01 = [1, 0, 1, 4, 10, 8, 1, 3, 3, 5]
      let lineData02 = [2, 1, 3, 3, 5, 6, 4, 10, 8, 1]
      let lineData03 = [1, 4, 10, 8, 4, 4, 4, 10, 15, 3]
      // var lineData01Max = Math.max.apply(null, lineData01);
      // var lineData02Max = Math.max.apply(null, lineData02);
      // var lineData03Max = Math.max.apply(null, lineData03);
      // let maxIndex = lineData01.indexOf(Math.max.apply(null, lineData01));
      // console.log(lineData01Max, lineData02Max, lineData03Max)

      let option = {
        tooltip: {
          trigger: 'axis',
          backgroundColor: 'rgba(8,45,74,0.85)',
          borderColor: 'rgb(140,255,74)', //设置边框颜色
          padding: 12,
          axisPointer: {
            type: 'shadow'
          },
          textStyle: {
            fontSize: 40,
            color: '#fff',
            align: 'left'
          },
          formatter: (params) => {
            let arr = [...params]
            let str = ''
            arr.forEach((item, index) => {
              str +=
                '<span style="margin-right:10px;display:inline-block;width:10px;height:10px;border-radius:5px;background-color:' +
                item.borderColor +
                ';"></span>' +
                item.seriesName +
                '  ' +
                item.data +
                '<br />'
            })
            str = arr[0].name + '<br />' + str
            return str
          }
        },
        grid: {
          left: '4%',
          right: '4%',
          bottom: '10%',
          top: '20%',
          containLabel: true
        },
        legend: {
          show: true,
          top: '8%',
          textStyle: {
            fontSize: 40,
            color: '#fff'
          }
          // data: ["煤化行业", "供热行业", "其他行业"],
        },
        xAxis: {
          show: true,
          type: 'category',
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          },
          axisLabel: {
            textStyle: {
              fontSize: 40,
              color: '#fff'
            }
          },
          data: ['2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024'],
          splitLine: {
            show: true,
            // interval: information.area.length,
            lineStyle: {
              color: 'rgba(180, 228, 255, 0.1)',
              width: 3
            }
          }
        },
        yAxis: [
          {
            name: '亿吨',
            nameTextStyle: {
              //y轴上方单位的颜色
              color: '#fff',
              fontSize: 40,
              padding: [0, 80, 15, 0]
            },
            type: 'value',
            axisLabel: {
              textStyle: {
                color: '#fff',
                fontSize: 40
              }
            },
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            splitLine: {
              show: false
            }
          }
        ],
        series: [
          {
            name: '建材行业',
            type: 'line',
            symbol: 'circle',
            itemStyle: {
              emphasis: {
                symbol: 'circle'
              }
            },
            symbolSize: 20, //标记的大小
            markPoint: {
              data: [
                {
                  type: 'max',
                  name: '最大值',
                  symbol:
                    'image://',
                  symbolSize: 110,
                  label: {
                    show: false
                  }
                }
              ]
            },

            lineStyle: {
              normal: {
                width: 5,
                color: 'rgba(196, 85, 26, 1)'
                // color: function (params) {
                //     // 通过判断当前数据点索引是否为最大值索引，改变颜色
                //     if (params.dataIndex === maxIndex) {
                //         return 'rgba(0,0,0,0.8)';  // 最大值折点阴影颜色
                //     }
                // },
              }
            },
            itemStyle: {
              //折线拐点标志的样式
              color: '#021958',
              borderColor: 'rgba(196, 85, 26, 1)',
              borderWidth: 5,
              label: {
                show: false
              }
            },
            data: lineData01
            // data: lineData01.map(function (value, index) {
            //     // 为最大值的数据点添加特殊样式
            //     return {
            //         value: value,
            //         // 通过 index 判断是否为最大值
            //         itemStyle: index === maxIndex ? {
            //             shadowBlur: 10, // 阴影的模糊大小
            //             shadowColor: 'rgba(196, 85, 26, 1)' // 阴影颜色
            //         } : {}
            //     };
            // })
          },
          {
            name: '炼焦行业',
            type: 'line',
            symbol: 'circle',
            symbolSize: 20, //标记的大小
            markPoint: {
              data: [
                {
                  type: 'max',
                  name: '最大值',
                  symbol:
                    'image://',
                  symbolSize: 110,
                  label: {
                    show: false
                  }
                }
              ]
            },
            itemStyle: {
              //折线拐点标志的样式
              color: '#021958',
              borderColor: 'rgba(127, 94, 204, 1)',
              borderWidth: 5
            },
            lineStyle: {
              normal: {
                width: 5,
                color: 'rgba(127, 94, 204, 1)'
              }
            },
            data: lineData02
          },
          {
            name: '冶金行业',
            type: 'line',
            symbol: 'circle',
            symbolSize: 20,
            itemStyle: {
              //折线拐点标志的样式
              color: '#021958',
              borderColor: 'rgba(89, 171, 217, 1)',
              borderWidth: 5
            },
            markPoint: {
              data: [
                {
                  type: 'max',
                  name: '最大值',
                  symbol:
                    'image://',
                  symbolSize: 110,
                  label: {
                    show: false
                  }
                }
              ]
            },
            lineStyle: {
              normal: {
                width: 5,
                color: 'rgba(89, 171, 217, 1)'
              }
            },
            data: lineData03
          }
        ]
      }

      chart.setOption(option, true)
    },
    getChartFour() {
      const chartsBar = echarts.init(this.$refs.pieChart4)

      let option = {
        tooltip: {
          trigger: 'axis',
          backgroundColor: 'rgba(8,45,74,0.85)',
          borderColor: 'rgb(140,255,74)', //设置边框颜色
          padding: 12,
          axisPointer: {
            type: 'shadow'
          },
          textStyle: {
            fontSize: 40,
            color: '#fff',
            align: 'left'
          }
        },
        legend: {
          icon: 'rect',
          itemWidth: 14,
          itemHeight: 5,
          itemGap: 13,
          // data: ['移动', '电信', '联通'],
          top: '8%',
          textStyle: {
            fontSize: 40,
            color: '#fff'
          }
        },
        grid: {
          top: 200,
          left: '5%',
          right: '5%',
          bottom: '5%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            axisLine: {
              lineStyle: {
                color: '#57617B'
              }
            },
            axisLabel: {
              interval: 0,
              align: 'center',
              margin: 10,
              color: '#fff',
              rotate: 0,
              textStyle: {
                fontSize: 40
              }
            },
            data: ['2017', '2018', '2019', '2020', '2021', '2022', '2022', '2024'],
            splitLine: {
              show: true,
              // interval: information.area.length,
              lineStyle: {
                color: 'rgba(180, 228, 255, 0.1)',
                width: 2
              }
            }
          },
          {
            axisPointer: {
              show: false
            },
            axisLine: {
              lineStyle: {
                color: '#57617B'
              }
            },
            axisTick: {
              show: false
            },

            position: 'bottom',
            offset: 20
          }
        ],
        yAxis: [
          {
            type: 'value',
            name: '亿吨',
            nameTextStyle: {
              color: '#fff',
              fontSize: 40,
              padding: [0, 0, 10, -20]
            },
            splitLine: {
              show: false
            },
            axisTick: {
              show: true
            },
            axisLine: {
              show: false
            },
            axisLabel: {
              show: true,
              textStyle: {
                color: '#fff',
                fontSize: 40
              }
            }
          },
          {
            type: 'value',
            name: '亿平方米',
            nameTextStyle: {
              color: '#fff',
              fontSize: 40,
              padding: [0, 0, 10, -20]
            },
            position: 'right',
            splitLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            axisLine: {
              show: false
            },
            axisLabel: {
              show: true,
              textStyle: {
                color: '#fff',
                fontSize: 40
              }
            }
          }
        ],
        series: [
          {
            name: '煤炭消费',
            type: 'line',
            symbolSize: 0, //标记的大小
            color: 'rgba(55, 204, 255, 1)',
            lineStyle: {
              color: 'rgba(55, 204, 255, 1)',
              width: 5
            },
            data: [42, 38, 48, 35, 29, 28, 3, 5]
          },
          {
            name: '房地产开工面积',
            type: 'line',
            // smooth: true,
            yAxisIndex: 1, //使用的 y 轴的 index，在单个图表实例中存在多个 y轴的时候有用
            symbol: 'circle',
            symbolSize: 0,
            showSymbol: false,
            lineStyle: {
              normal: {
                color: 'rgba(255, 195, 0, 1)',
                width: 5
              }
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: 'rgba(255, 195, 0, 0.4)'
                    },
                    {
                      offset: 0.8,
                      color: 'rgba(255, 195, 0, 0.2)'
                    }
                  ],
                  false
                ),
                shadowColor: 'rgba(255, 195, 0, 0.2)',
                shadowBlur: 10
              }
            },
            itemStyle: {
              normal: {
                color: 'rgba(255, 195, 0, 1)',
                borderColor: 'rgba(255, 195, 0, 0.2)',
                borderWidth: 2
              }
            },
            data: [120, 110, 125, 145, 122, 165, 122, 220]
          }
        ]
      }
      chartsBar.setOption(option, true)
    }
  }
})
</script>

<style lang="scss" scoped>
.right-content-box {
  width: 4339px;
  height: 1830px;
  // height: 1700px;
  display: flex;
  flex-wrap: wrap;
  box-sizing: border-box;
  margin: 0 200px;

  .qiuChart {
    width: 576px;
    height: calc(50% - 90px);
  }

  .pageTitle {
    width: 4339px;
    text-align: center;
    position: absolute;
    color: #fff;
    font-size: 60px;
    margin-top: -186px;
    height: 120px;
    line-height: 120px;
  }

  .contentItem {
    flex: 1;
    width: calc(50% - 580px);
    height: calc(50% - 90px);
    // min-width: 50%;
    max-width: 50%;
    padding: 20px 20px 20px 20px;
    box-sizing: border-box;
    margin-left: 80px;

    .titleBox {
      width: 1801px;
      line-height: 10px;
      text-align: center;

      .title {
        height: 100%;
        font-size: 53px;
        color: #fff;
      }
    }
  }
}
</style>
